package com.v2future.sjt.collegecheckingattendance.common.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.v2future.sjt.collegecheckingattendance.MainActivity;
import com.v2future.sjt.collegecheckingattendance.R;
import com.v2future.sjt.collegecheckingattendance.utils.DensityUtil;

import org.xutils.image.ImageOptions;
import org.xutils.x;

import me.nereo.multi_image_selector.bean.Image;

/**
 * Created by Administrator on 2016/3/13.
 */
public class ImageActivity extends MainActivity{

    private LinearLayout bgLayout;
    private ImageView imageIv;

    private String imageUrl;
    public static final String IMAGE_URL = "image_url";

    /**
     * init first
     */
    @Override
    public void init() {
        imageUrl = getIntent().getStringExtra(IMAGE_URL);
    }

    /**
     * init view
     */
    @Override
    public void initView() {
        setContentView(R.layout.activity_image);
        bgLayout = (LinearLayout) findViewById(R.id.layout_bg);
        imageIv = (ImageView) findViewById(R.id.iv_image);
    }

    /**
     * init after
     */
    @Override
    public void initAfter() {
        ImageOptions options = new ImageOptions.Builder()
                .setImageScaleType(ImageView.ScaleType.CENTER_CROP)
                .setFailureDrawableId(R.mipmap.ic_img_load_error)
                .setLoadingDrawableId(R.mipmap.ic_album)
                .build();
        x.image().bind(imageIv, imageUrl, options);
        bgLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
